﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UM_SERVER.ProcessModel;
using UM_SERVER.Session;

namespace UM_SERVER.User
{
    /// <summary>
    ///     用户基类
    /// </summary>
    public abstract class User : IMetaData
    {
        public User(String Key)
        {
            this.key = Key;
        }


        private Level.MessionLevel mession;
        private String username;
        private int videoPort;
        private int voicePort;
        private int talkPort;
        private int transferFilePort;
        /// <summary>
        ///     文件传送端口
        /// </summary>
        public int TransferFilePort
        {
            get { return transferFilePort; }
            set { transferFilePort = value; }
        }
        private String ipAddress;
        private DateTime onlineTime;
        private DateTime offlineTime;
        private UM_SERVER.Packet.InPacket.LoginPacket.LoginState loginLive;

        #region 用户属性

        /// <summary>
        ///     登陆类别
        /// </summary>
        public UM_SERVER.Packet.InPacket.LoginPacket.LoginState LoginLive
        {
            get { return loginLive; }
            set { loginLive = value; }
        }

        /// <summary>
        ///     用户权限
        /// </summary>
        public Level.MessionLevel Mession
        {
            get { return mession; }
            set { mession = value; }
        }

        /// <summary>
        ///     用户名
        /// </summary>
        public string Username
        {
            get { return username; }
            set { username = value; }
        }

        /// <summary>
        ///     视频端口 [UDP]
        /// </summary>
        public int VideoPort
        {
            get { return videoPort; }
            set { videoPort = value; }
        }

        /// <summary>
        ///     音频端口 [UDP]
        /// </summary>
        public int VoicePort
        {
            get { return voicePort; }
            set { voicePort = value; }
        }

        /// <summary>
        ///     聊天端口 [UDP]
        /// </summary>
        public int TalkPort
        {
            get { return talkPort; }
            set { talkPort = value; }
        }

        /// <summary>
        ///     IP地址
        /// </summary>
        public string IpAddress
        {
            get { return ipAddress; }
            set { ipAddress = value; }
        }

        /// <summary>
        ///     上线时间
        /// </summary>
        public DateTime OnlineTime
        {
            get { return onlineTime; }
            set { onlineTime = value; }
        }

        /// <summary>
        ///     下线时间
        /// </summary>
        public DateTime OfflineTime
        {
            get { return offlineTime; }
            set { offlineTime = value; }
        }

        #endregion

        /// <summary>
        ///     向用户广播 消息/命令
        /// </summary>
        /// <param name="Content" type="byte[]">
        ///     <para>
        ///         要广播的内容
        ///     </para>
        /// </param>
        public abstract void Boardcast(byte[] Content);
        /// <summary>
        ///     强制用户下线
        /// </summary>
        public void SetOffline(Session.Session UserSession)
        {
            ProcessUserModel.SetUserOffline(this, UserSession);
        }

        #region IMetaData 成员

        private String key;
        public string Key
        {
            get
            {
                return key;
            }
            set
            {
                key = value;
            }
        }

        #endregion
    }
}
